package com.javabi.htmlbuilder.css.unit;

import com.javabi.htmlbuilder.css.CSSBuilder;
import com.javabi.htmlbuilder.css.CSSElement;

/**
 * A CSS Unit Number.
 */
public abstract class CSSUnitNumber implements CSSElement {

	/** The number. */
	private final int number;

	/**
	 * Creates a new unit number.
	 * @param number the number.
	 */
	protected CSSUnitNumber(int number) {
		this.number = number;
	}

	/**
	 * Returns the number.
	 * @return the number.
	 */
	public final int getNumber() {
		return number;
	}

	/**
	 * Returns the unit.
	 * @return the unit.
	 */
	public abstract CSSUnit getUnit();

	/**
	 * Append this to the given css builder.
	 * @param css the css builder.
	 * @return the css builder.
	 */
	public CSSBuilder appendTo(CSSBuilder css) {
		css.number(getNumber(), getUnit());
		return css;
	}

}
